//
//  UIView+Extension.m
//  06-屏幕截图
//
//  Created by apple on 15/9/4.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "UIView+Extension.h"

@implementation UIView (Extension)
-(UIImage *)capture{
    // 开启上下文
    UIGraphicsBeginImageContext(self.frame.size);
    // 将图层内容渲染到上下文
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    // 获得图片
    UIImage *newImage =  UIGraphicsGetImageFromCurrentImageContext();
    // 关闭上下文
    UIGraphicsEndImageContext();
    
    return newImage;
}
@end
